package top.shiyiri.spring5.testdemo;

import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import top.shiyiri.spring5.bean.Emp;
import top.shiyiri.spring5.service.UserService;

/**
 * @author Aunean
 * @date 2022/2/16 18:46
 */
public class TestBean {

    @Test
    public void testAdd() {
        //1.加载spring配置文件
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("bean2.xml");

        //2.获取配置创建的对象
        UserService userService = context.getBean("userService", UserService.class);
        userService.add();
    }

    @Test
    public void testAdd2() {
        //1.加载spring配置文件
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("bean3.xml");

        //2.获取配置创建的对象
        Emp emp = context.getBean("emp", Emp.class);
        emp.add();
    }

    @Test
    public void testAdd3() {
        //1.加载spring配置文件
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("bean4.xml");

        //2.获取配置创建的对象
        Emp emp = context.getBean("emp", Emp.class);
        emp.add();
    }
}
